using System;
using System.Drawing;
using Microsoft.TeamFoundation.Build.Proxy;

namespace Nuwanda.TfsSpotlight.Data
{
    public class BuildDataDescriptor
    {
        public string CurrentUserName { get; set; }
        public string Number { get; set; }
        public string Status { get; set; }
        public string Uri { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime FinishTime { get; set; }
        public string RequestedBy { get; set; }

        public bool IsForCurrentUser
        {
            get { return this.RequestedBy.Equals(this.CurrentUserName); }
        }

        public Color Color
        {
            get
            {
                var color = Color.White;
                switch (this.Status)
                {
                    case "Successfully Completed": color = Color.Honeydew;
                        break;
                    case "Stopped": color = Color.Linen;
                        break;
                    case "Failed": color = Color.LavenderBlush;
                        break;
                }

                return color;
            }
        }

        public BuildDataDescriptor(BuildData buildData, string currentUserName)
        {
            this.CurrentUserName = currentUserName;
            this.Number = buildData.BuildNumber;
            this.Status = buildData.BuildStatus;
            this.Uri = buildData.BuildUri;
            this.StartTime = buildData.StartTime;
            this.FinishTime = buildData.FinishTime;
            this.RequestedBy = buildData.RequestedBy;
        }
    }
}